home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 7
/
FM Towns Free Software Collection 7.iso
/
taropyon
/
znsplay
/
src
/
znsmov.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-30
|
3KB
|
109 lines
/*************************************************************************
* "znsmov.c"
*************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <egb.h>
#include <ugoku.h>
#include "znsplay.h"
/* graphic init */
static int moving_graph_init( int md, int x0, int y0, int x1, int y1 )
{
int x, y;
static struct _tbl_t
{ int dx, dy, vx, vy, ox, oy;
} tbl[4] =
{ { 320,240, 160,120, 0, 0 }, /* ×1 */
{ 320,240, 0, 0, 0, 0 }, /* ×2 */
{ 213,160, 0, 0, 54, 40 }, /* ×3 */
{ 160,120, 0, 0, 80, 60 }, /* ×4 */
};
struct _tbl_t *ptr;
FRAME fr; /* 640×480画面に換算して */
if ( md < 1 )
md = 1;
else if ( md > 4 )
md = 4;
ptr = &tbl[md-1];
if( x0 == 0 && y0 == 0 && x1 == 0 && y1 == 0 )
{
x1 = 319;
y1 = 239;
}
x = ((x0+x1+1) >> 1) - 160; /* 絵の中心のずれを計算 */
y = ((y0+y1+1) >> 1) - 120;
ZNS_cls();
if ( DspCtrl.page0 != 10 )
{
EGB_resolution(EgbPtr,0,10);
DspCtrl.page0 = 10;
DspCtrl.scinf[0].md = 10;
EGB_displayPage(EgbPtr,1,3);
page1_palette();
}
DSP_writePage(0);
ZNS_displayStart(2,md,md); /* 画面の拡大 */
ZNS_displayStart(3,ptr->dx,ptr->dy); /* 表示画面の大きさ */
ZNS_displayStart(0,ptr->vx,ptr->vy); /* 画面の表示開始一の設定 */
x = ptr->ox + x;
y = ptr->ox + y;
ZNS_displayStart(1,x,y); /* 仮想画面中の移動 */
fr.x1 = ptr->vx + (x0-x) * md;
fr.y1 = ptr->vy + (y0-y) * md;
fr.x2 = ptr->vx + (x1-x) * md + md - 1;
fr.y2 = ptr->vy + (y1-y) * md + md - 1;
ZNS_frame( &fr );
return (0);
}
int zns_play_mov( ZNSMOVE_T *znsmove )
{
int frame, x0, y0, x1, y1, wsize;
int error;
char *buf, *work;
if ( znsmove->mode == ZNS_MODE_MEMORY )
{
error = mov_memory_play_init(
znsmove->filename, ZnsNextCheck, &frame,&x0,&y0,&x1,&y1, &wsize );
} else
{
error = mov_disk_play_init(
znsmove->filename, ZnsNextCheck, &frame,&x0,&y0,&x1,&y1, &wsize );
}
if( error ) return error;
moving_graph_init( znsmove->expand, x0, y0, x1, y1 );
if ( (buf = malloc( 153600 )) == NULL )
{
return 7; /* out of memory */
}
if ( (work = malloc( wsize )) == NULL )
{
free( buf );
return 7; /* out of memory */
}
if ( znsmove->mode == ZNS_MODE_MEMORY )
error = mov_memory_play( buf, work, znsmove->filename, 0, znsmove->wait );
else
error = mov_disk_play ( buf, work, znsmove->filename, 0, znsmove->wait );
free( buf );
free( work );
return error;
}